﻿//*  番茄每周福利 *//
//* 作者：50009219*//

var status = 0;
var random = java.lang.Math.floor(Math.random() * 4);
var a = "#fEffect/CharacterEff/1114000/1/0#"; //红色六芒星
var b = "#fEffect/CharacterEff/1003271/0/0#";
var c = "#fEffect/CharacterEff/1112905/0/0#"; //篮心
var d = "#fEffect/CharacterEff/1002667/0/0#"; //黄星
var e = "#fEffect/CharacterEff/1003252/1/0#"; //音乐
var g = "#fEffect/CharacterEff/1082565/0/0#"; //饼干兔子
var h = "#fUI/Basic/BtHide3/mouseOver/0#";
var f = "#fEffect/CharacterEff/1112904/2/1#";//彩色五角星

var ca = java.util.Calendar.getInstance();
var year = ca.get(java.util.Calendar.YEAR); //获得年份
var month = ca.get(java.util.Calendar.MONTH) + 1; //获得月份
var day = ca.get(java.util.Calendar.DATE);//获取日
var hour = ca.get(java.util.Calendar.HOUR_OF_DAY); //获得小时
var minute = ca.get(java.util.Calendar.MINUTE);//获得分钟
var second = ca.get(java.util.Calendar.SECOND); //获得秒
var weekday = ca.get(java.util.Calendar.DAY_OF_WEEK); //获得星期
var time = new Date();
var sjr = time.getDay();
switch (sjr) {
    case 0:
        var xq = "星期日";
        break;
    case 1:
        var xq = "星期一";
        break;
    case 2:
        var xq = "星期二";
        break;
    case 3:
        var xq = "星期三";
        break;
    case 4:
        var xq = "星期四";
        break;
    case 5:
        var xq = "星期五";
        break;
    case 6:
        var xq = "星期六";
        break;
    default:
}
if (hour > 20) {
    hour -= 20;
    var apm = "下午好";
} else {
    var apm = "上午好";
}
function start() {
    status = -1;
    action(1, 0, 0);
}

var bossId = "";
//领取的礼物列表
var gifts = Array(
	//物品ID， 数量
	Array(4000463, 100),
	Array(5062000, 50),
	Array(5062002, 50),
	Array(5062500, 50),
	Array(4001715, 1),
	Array(3010453, 1)
);
//奖励的点卷数量, 设置为0则不奖励
var giftAcash = 0;
//奖励的抵用券数量, 设置为0则不奖励
var giftMpoints = 0;
//奖励的游戏币数量, 设置为0则不奖励
var giftMeso = 0;


function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }
    if (cm.getMapId() == 180000001) {
        cm.sendOk("很遗憾，您因为违反用户守则被禁止游戏活动，如有异议请联系管理员.")
        cm.dispose();
    } else if (status == 0) {
        var selStr = "#e#r\t\t\t\t每周福利天堂\r\n\r\n#k#n";
        selStr += e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + "\r\n\r\n";
        selStr += "  #b" + g + " 每周日开放 [ 5 ] 分钟 请玩家按照时间领奖品 " + g + "\r\n#k";
        selStr += "  #b" + g + " 提示 - 进行游戏 [ 60 ] 分钟 开放[ 5 ] 分钟 " + g + "\r\n#k";
        selStr += "  #b" + g + " 当前周期 #r[ " + xq + " #b] 　 已进行游戏：#r" + cm.getGamePoints() + "#b 分钟 " + g + "\r\n\r\n";
        selStr += "\t\t\t\t#e#r#L0#领取每周福利#l\r\n#k#n\r\n";
        selStr += "\t\t\t\t#e#r#L1#女神每周福利#l\r\n#k#n\r\n\r\n";
        selStr += e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + e + "\r\n";
        cm.sendSimple(selStr);
    } else if (status == 1) {
        switch (selection) {
            case 0://奖品
                if (sjr == 0) {
                    if (cm.getGamePoints() > 60) {
                        if (cm.getEventCount("每周小福利") < 1) {
                            cm.gainNX(2, 50000);//抵用卷
                            cm.gainItem(4033356, 5, 7);//火种
                            cm.gainItem(2049100, 5);//混沌 60%
                            cm.gainItem(2049116, 3);//强化混沌
                            cm.gainItem(4001839, 100);//星星
                            cm.gainItem(2431987, 1);//周年庆
                            cm.gainItem(4000082, 15);//僵尸的金齿
                            var ii = cm.getItemInfo();
                            var toDrop = ii.randomizeStats(ii.getEquipById(1112779)).copy(); // 生成一个Equip类 
                            var timeStamp = java.lang.System.currentTimeMillis();
                            var expirationDate = timeStamp + 432000000;// 五天
                            toDrop.setExpiration(expirationDate);//时间
                            toDrop.setStr(30); //装备力量
                            toDrop.setDex(30); //装备敏捷
                            toDrop.setInt(30); //装备智力
                            toDrop.setLuk(30); //装备运气
                            toDrop.setAcc(30); //命中率
                            toDrop.setMatk(30); //魔法攻击
                            toDrop.setWatk(30); //攻击攻击 
                            toDrop.setOwner("★每周福利★");//签名
                            cm.addFromDrop(cm.getC(), toDrop, false);
                            cm.sendOk("\t\t\t\r\n\r\n#e#r恭喜您！你已领取了每周福利礼包！！");
                            cm.setEventCount("每周小福利", 1);
                            cm.dispose();
                        } else {
                            cm.sendOk("\t\t\t\r\n\r\n#e#r抱歉！本周奖品已领！请等待下周！！");
                            cm.dispose();
                        }
                    } else {
                        cm.sendOk("\t\t\t\r\n\r\n#e#r抱歉！今天进行游戏 [ 60 ] 分钟 未达标！");
                        cm.dispose();
                    }
                } else {
                    cm.sendOk("\t\t\t\r\n\r\n#e#r抱歉！今天不是 [ 星期日 ] 无法参与！");
                    cm.dispose();
                }
                break;
            case 1://女神
                /* 是否佩戴或拥有官方认证勋章 */
                if (cm.haveItem(1142574) || cm.getPlayer().getMedalText().indexOf("官方认证女生") != -1) {
                    /* 允许领取奖励 */
                    if (cm.getBossLogAcc(bossId) != -1) {
                        /* 插入记录 */
                        cm.setBossLogAcc(bossId, -2);
                        /* 领取奖励 */
                        var text = "恭喜您，成功领取以下奖励：\r\n";
                        if (giftAcash != 0) {
                            cm.gainNX(1, giftAcash);
                            text += "点卷 #bx" + giftAcash + "#k\r\n";
                        }
                        if (giftMpoints != 0) {
                            cm.gainNX(2, giftMpoints);
                            text += "抵用券 #bx" + giftMpoints + "#k\r\n";
                        }
                        if (giftMeso != 0) {
                            cm.gainMeso(giftMeso);
                            text += "游戏币 #bx" + giftMeso + "#k\r\n";
                        }
                        /* 遍历物品奖励 */
                        for (var i in gifts) {
                            var itemid = gifts[i][0];
                            var quantity = gifts[i][1];
                            cm.gainItem(itemid, quantity);
                            text += "#t" + itemid + "# #bx" + quantity + "#k\r\n";
                        }
                        cm.sendOk(text);
                        cm.dispose();
                    } else {
                        cm.sendOk("您已经领取过本周的奖励，请下周再来。");
                        cm.dispose();
                    }
                } else {
                    cm.sendOk("你好像没有拥有官方认证勋章，无法领取奖励。");
                    cm.dispose();
                }
                break;
        }
    }
}
